const mysql = require('mysql');
const redisClient = require("redis");
const redis = redisClient.createClient(6379, 'localhost');

redis.setnx('node', JSON.stringify({a:1, b:2})) //value会被转为Object,所以存的时候要先把value 转为json字符串
redis.get('node', function(err, value){
    if(err) throw err;
    console.log(JSON.parse(value));
})

redis.hgetall("maps", (err, value) => console.log(value));

const conn = mysql.createConnection({
  host     : 'localhost',
  user     : 'root',
  password : 'root',
  database : 'baimi'
});

conn.connect(function(err, args) {
    // console.log(args);
});

conn.query('SELECT * from tbl_user where id = 20;', function (error, results, fields) {
  if (error) throw error;
  console.log(results);
});

conn.end(function(err, args) {
    console.log(args);
});